<?php
$server	    = 'localhost';
$username	= 'root';
$password	= 'grouptwo';
$database	= 'test';
$connect=mysql_connect($server, $username, $password);
 if(!$connect){
 exit('Error: can not connect to the server'); 
 }
$select=mysql_select_db($database);
if(!$select)
{
 	  exit('Error: can not select the database');
} 	
$imgData = file_get_contents($filename);
$size = getimagesize($filename);
mysql_connect("localhost", "$username", "$password");
mysql_select_db ("$database");
$sql = sprintf("INSERT INTO `testlob`(`image_id`, `image_type`, `image`, `image_size`, `image_ctgy`, `image_name`)
    VALUES('%s', '%s', '%d', '%s')", mysql_real_escape_string($size['mime']), mysql_real_escape_string($imgData),$size[3],
   mysql_real_escape_string($_FILES['userfile']['name']));   
$insert=mysql_query($sql);
if(!$insert){
	echo "<p>".mysql_error(). "<p>";
	}
?>